Primitive gonads develop from cells derived from both ectoderm (in the yolk sac) and mesoderm (in the urogenital ridge). Although initially undifferentiated, sexual dimorphism first appears at around 6 weeks, after which the gonads and sexual apparatus follow separate developmental pathways according to the hormonal environment.
In the adult, both gonads (testes and ovaries) have two roles: the production of gametes (spermatozoa and ova) and the production of sex hormones (testosterone and oestrogen).